/*
============================================================================
 Name        : dd_http_worker.h
 Author      : Jian
 Version     :
 Copyright   : GPL
 Description : dd_http_worker.h - header file
============================================================================
*/

#ifndef DD_HTTP_WORKER_H
#define DD_HTTP_WORKER_H

/* INCLUDES */
#include "dd_define.h"
#include "dd_http.h"

__DD_BEGIN_DECLS

struct __dd_task_worker ;
typedef struct __dd_http_worker dd_http_worker;

struct __dd_http_worker {
    struct __dd_task_worker* taskWorker ;
} ;

/* 
* startTaskId: task id, it will be auto-inc when add a new task
* threadCount: if threadCount is not specify(<= 0), it will be set as (2 *sd_get_cpu_count())
*/
dd_http_worker* dd_http_worker_create(DD_UINT startTaskId, int threadCount) ;

void dd_http_worker_destroy(dd_http_worker* worker) ;

/* 
*  DONT do any free req memory logic until the http work is finished(when the dd_http_callback.finish() was call) 
*  return -1, mean got some error 
*/
DD_UINT dd_http_worker_get(dd_http_worker* worker, const dd_http_req_get* req, int isEnableMultiGet, int priority) ;

DD_UINT dd_http_worker_post_buf(dd_http_worker* worker, const dd_http_req_post_buf* req, int priority) ;

DD_UINT dd_http_worker_post_file(dd_http_worker* worker, const dd_http_req_post_file* req, int priority) ;

DD_UINT dd_http_worker_head(dd_http_worker* worker, const dd_http_req_head* req, int priority) ;

int dd_http_worker_cancel(dd_http_worker* worker, DD_UINT taskId) ;

__DD_END_DECLS	

#endif  /* DD_HTTP_WORKER_H */

/* End of File */
